/*
 * Copyright 2012 Nicholas Bilyk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
package Views {
	
	import Util.ViewUtil;
	import Util.NumberUtil;
	import cocos2d.CCArray;
	import cocos2d.CCSpriteFrameCache;
	import cocos2d.CCAnimation;
	import cocos2d.CCAnimate;

	public class Block extends Piece {

		private static var pushAnimation:CCAnimation;

		// Moves left
		private var _movesLeft:uint;

		protected var totalMoves:uint = 1;
		
		public function Block() {
			super();
			_movesLeft = totalMoves;
			view = ViewUtil.createSprite("Block0000");
			if (pushAnimation == null) pushAnimation = ViewUtil.createAnimation("Block", 0, 4);
		}

		public function get movesLeft():uint {
			return _movesLeft;
		}

		public function set movesLeft(v:uint):void {
			_movesLeft = v;
			if (_movesLeft == 0) view.runAction(CCAnimate.create(pushAnimation));
		}
	}
}